package com.example.bff.driver.config;

import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject: hxds
 * @BelongsPackage: com.example.bff.driver.config
 * @Author: caohaoran
 * @CreateTime: 2025-10-19  23:43
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
public class MultipartSupportConfig {

    @Autowired
    //ObjectFactory<HttpMessageConverters>：Spring的工厂模式封装，通过getObject()方法可获取当前应用的HTTP消息转换器集合。
    private ObjectFactory<HttpMessageConverters> messageConverters;

    @Bean
    public Encoder feignFormEncoder(){
        return new SpringFormEncoder(new SpringEncoder(messageConverters));
    }
}
